Β 

Linux Quickstart πŸ§πŸš€

Published at Nov 27, 2024

# linux# terminal

πŸ‘‹ Introduction

Welcome to this quick start guide for Linux! The goal isn’t to memorize every command, but to understand the workflow and learn how to learn. Stick around for a bonus tip at the end! 🎁

Basic Commands

ls - List Directory Contents πŸ—‚οΈ

When you first open a terminal, it might feel like a dark and empty abyss. Let’s turn on the lights with ls πŸ’‘.

  • What it does: Lists information about files and directories. By default, it sorts entries alphabetically.
  • Finding out more: Use man ls to see the manual page.

Common Parameters (Flags)

Parameters modify how a command works. They usually have a short (-a) and long (--all) form.

  • -a or --all: Show all entries, including hidden files (those starting with .).
  • -l: Use a long listing format. This shows permissions, owner, group, size, modification date, and filename.
  • -r or --reverse: Reverse the order of the sort.
  • -t: Sort by modification time, newest first. Combine with -l to see the times (ls -lt).

Example Usage:

ls         # Basic listing
ls -a      # List all files (including hidden)
ls -l      # Long listing format
ls -al     # Long listing of all files
ls -alr    # Long listing, all files, reversed order
ls -lt     # Long listing, sorted by time (newest first)

Quick Tip: Use Ctrl+L to clear the terminal screen.


man - The System Manual πŸ“–

man is your key πŸ”‘ to understanding commands.

  • What it does: Displays the system’s reference manuals (manual pages) for commands, utilities, or functions. It uses a pager program like less to display the content.
  • Usage: man <command_name> (e.g., man ls, man man).

Press h inside man for a help screen.

  • Moving:
    • ↓ / ↑ or Enter: Move down/up one line.
    • Spacebar / PageDown: Move down one page.
    • PageUp: Move up one page.
  • Jumping:
    • gg: Go to the beginning of the page.
    • G (Shift+g): Go to the end of the page.
  • Searching:
    • /search_term: Search forward for search_term.
    • ?search_term: Search backward for search_term.
    • n: Go to the next search result (in the direction you searched).
    • N (Shift+n): Go to the previous search result.
  • Quitting:
    • q: Quit the man page viewer.

Example: Let’s find the time sorting option in ls.

  1. Open the manual: man ls
  2. Search forward for β€œtime”: /time
  3. Press n to cycle through results until you find the -t flag.

Understanding the Hierarchy π“Š

The Linux file system is a hierarchy, like an inverted tree 🌳 or a staircase, starting from the root directory (/).

  • Root Directory: / - The top level.
  • Home Directory: /home/<username> (e.g., /home/crispy) - Your personal space.
  • Path Separator: / - Used to separate directories in a path.

You can visualize the structure using the tree command

cd - Change Directory

  • What it does: Changes your current working directory.

Paths

  • Absolute Path: Specifies the location from the root directory (/). Always starts with /.
    • Example: cd /home/crispy/Documents
  • Relative Path: Specifies the location relative to your current directory. Does not start with /.
    • . (dot): Represents the current directory.
    • .. (dot-dot): Represents the parent directory (one level up).
    • Example: If you are in /home/crispy:
      • cd Documents (or cd ./Documents) moves into the Documents subdirectory.
      • cd .. moves up to /home.

Example Workflow:

pwd                # Check current directory (e.g., /home/crispy)
cd /home/crispy    # Go to home using absolute path
pwd                # Confirm: /home/crispy
cd Documents       # Go down into Documents (relative path)
pwd                # Confirm: /home/crispy/Documents
cd ..              # Go up one level (relative path)
pwd                # Confirm: /home/crispy

pwd - Print Working Directory

  • What it does: Shows the full path of your current directory.

Viewing Files πŸ‘€

cat - Concatenate and Display Files πŸ“œ

  • What it does: Reads files sequentially and writes their content to standard output (your terminal).
  • Concatenation: If you provide multiple filenames, cat displays them one after the other.

Example Usage:

# Display a single file
cat reminder.txt

# Display multiple files, one after the other
cat file1.txt file2.txt file3.txt

Bonus: Quick References with curl and cheat.sh 🎁

Sometimes you just need a quick reminder or example. cheat.sh is a community-driven cheat sheet service accessible via curl 🌐.

curl - Transfer Data from URLs

  • What it does: A versatile tool to transfer data using various protocols, including HTTP/HTTPS for web pages.
  • Basic Usage: curl <url>

cheat.sh - Command Cheat Sheets

  • Access: curl cheat.sh
  • Get help for a specific command: curl cheat.sh/<command_name>
  • Short alias: Often, cht.sh works too: curl cht.sh/<command_name>

Example Usage:

curl cheat.sh          # General help/intro
curl cheat.sh/ls       # Cheat sheet for ls
curl cht.sh/grep       # Cheat sheet for grep
curl cheat.sh/tar      # Cheat sheet for tar

cheat.sh provides common use cases, explanations, and often a TL;DR section for very quick examples. Explore the :help and :intro sections (curl cheat.sh/:help).


Conclusion 🎯

We’ve covered the basics:

  • ls: Listing files πŸ—‚οΈ
  • man: Reading manuals πŸ“–
  • cd, pwd: Navigating directories 🌲
  • cat: Viewing files πŸ“œ
  • curl, cheat.sh: Getting quick help 🌐

The key is not memorizing absolutely everything 🧠 but knowing how to find information (man, cheat.sh) and understanding how Linux works from a high level πŸ›Έ

Keep exploring, stay curious, and practice! πŸš€

Crispyfish Tech Β© 2025